package com.vipheyue.lanjingapp.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.lidroid.xutils.util.LogUtils;
import com.vipheyue.lanjingapp.R;
import com.vipheyue.lanjingapp.bean.EmployeeBean;
import com.vipheyue.lanjingapp.bean.Job;

import java.util.ArrayList;

import butterknife.ButterKnife;
import cn.bmob.v3.datatype.BmobFile;
import cn.bmob.v3.listener.SaveListener;

public class CRDUActivity extends AppCompatActivity {

    private ArrayList<BmobFile> imageList;
    private Job job;
    private String path2;
    private String ram = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
//        setContentView(R.layout.activity_job_detail_content);
        ButterKnife.bind(this);
//        tv_description.setText("松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送松松送送送送送送送送送送送送送送送送送送送送送送送送送送送送");
        for (int i = 0; i <30; i++) {
            createNewObj("",+i);
        }
//        for (int i = 0; i < 40; i++) {
//            createNewEmployee("9943" + i);
//        }
    }

    private void createNewEmployee(String s) {
        EmployeeBean employeeBean = new EmployeeBean();
        employeeBean.setEmployeeCompanyName("仕达利恩");
        employeeBean.setEmployeeID(s);
        employeeBean.setEmployeeNAME("范冰冰");
        employeeBean.setEmployeeMale(false);
        employeeBean.setEmployeeInterviewDate("2015年12月11日");
        employeeBean.setEmployeeCheckInDate("2015年12月12日");
        employeeBean.setEmployeeCheckOutDate("2016年2月2日");
        employeeBean.setEmployeeWorkTEN("500");
        employeeBean.setEmployeeWorkDays("10天");
        employeeBean.setEmployeeSource("军明");
        employeeBean.setEmployeeWorking(true);
        employeeBean.setEmployeeOutWorkDate("");
        employeeBean.setEmployeeOtherInfo("");
        employeeBean.save(CRDUActivity.this, new SaveListener() {
            @Override
            public void onSuccess() {
                Toast.makeText(CRDUActivity.this, "上传成功", Toast.LENGTH_LONG).show();
                LogUtils.i("上传成功");
            }

            @Override
            public void onFailure(int i, String s) {
                Toast.makeText(CRDUActivity.this, "上传失败" + s, Toast.LENGTH_LONG).show();
                LogUtils.i("上传失败" + s);

            }
        });
    }

    private void createNewObj(final String path, int i) {
        job = new Job();
//        Company company = new Company();
//        company.setObjectId(UriConfig.releaseCompanyId);
//        job.setPublisherCompany(company);
        job.setJobTitle("招聘程序员" );
        job.setJobType("实习");
        job.setPartTimeJob(true);
        job.setWorkAreaType("重庆");
        job.setWorkAddressDetail("重庆九龙坡石桥铺协和医院");
        job.setContactAddress("广州-佛山");
        job.setEducationLevel("本科");
        job.setMinSalary("100");
        job.setMaxSalary("200");
        job.setContactsPeople("张泽瀛");
        job.setSalaryType("天");
        job.setWorkDay("周末");
        job.setContactsPhone("18584500435");
        job.setDetailDescription("１、综合工资3500~4000元/月，底薪1710元，生产奖金300元/月,全勤奖400元/月，夜班津贴10元/天.\r\n" +
                "2、加班费按国家标准另外发给。周一至周五8小时外加班算1.5倍,周六周日2倍的加班全天计算,国家法定节日算3倍加班\r\n");
        job.setJobRebate("女孩工作满15天返2000元/人，男孩工作满15天返1000元/人");
        ArrayList<String> list = new ArrayList<>();
        list.add("五险一金");
        list.add("公积金");
        list.add("包吃包住");
        job.setJobWelfareList(list);
        job.setAgeLimit("18-40岁");
        job.setIsMale(true);

        job.setCompanyDescription("酷牛专注移动端应用开发、微信开发、网页设计,相信互联网能够创造公平的竞争环境，让小企业通过创新与科技扩展业务，并在参与国内或全球市场竞争时处于更有利的位置。");
        job.setCompanyName("重庆酷牛科技");
        job.setDisplay(true);
//        BTPFileResponse response = BmobProFile.getInstance(this).upload(path, new UploadListener() {
//
//            @Override
//            public void onSuccess(String fileName,String url,BmobFile file) {
//                Log.i("bmob", "文件上传成功：" + fileName + ",可访问的文件地址：" + file.getUrl());
//                // TODO Auto-generated method stub
//                // fileName ：文件名（带后缀），这个文件名是唯一的，开发者需要记录下该文件名，方便后续下载或者进行缩略图的处理
//                // url        ：文件地址
//                // file        :BmobFile文件类型，`V3.4.1版本`开始提供，用于兼容新旧文件服务。
////                注：若上传的是图片，url地址并不能直接在浏览器查看（会出现404错误），需要经过`URL签名`得到真正的可访问的URL地址,当然，`V3.4.1`的版本可直接从'file.getUrl()'中获得可访问的文件地址。
//                job.setCompanyLogo(file);
//            }
//
//            @Override
//            public void onProgress(int progress) {
//                // TODO Auto-generated method stub
//                Log.i("bmob","onProgress :"+progress);
//            }
//
//            @Override
//            public void onError(int statuscode, String errormsg) {
//                // TODO Auto-generated method stub
//                Log.i("bmob","文件上传失败："+errormsg);
//            }
//        });


        job.save(CRDUActivity.this, new SaveListener() {
            @Override
            public void onSuccess() {
                Toast.makeText(CRDUActivity.this, "上传成功", Toast.LENGTH_LONG).show();
                LogUtils.i("上传成功");
            }

            @Override
            public void onFailure(int i, String s) {
                Toast.makeText(CRDUActivity.this, "上传失败" + s, Toast.LENGTH_LONG).show();
                LogUtils.i("上传失败" + s);

            }
        });



    }
}
